#ifndef BUBBLESORTWINDOW_H
#define BUBBLESORTWINDOW_H

#include <QMainWindow>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QSpinBox>
#include <QLabel>
#include <QTimer>
#include <QVector>
#include <QPainter>
#include <QGraphicsScene>
#include <QGraphicsView>

class BubbleSortWindow : public QMainWindow
{
    Q_OBJECT

public:
    BubbleSortWindow(QWidget *parent = nullptr);
    ~BubbleSortWindow();

private slots:
    void generateRandomArray();
    void startSorting();
    void stepSort();
    void resetArray();

private:
    void drawArray();
    void swapElements(int i, int j);
    
    QWidget *centralWidget;
    QVBoxLayout *mainLayout;
    QHBoxLayout *controlLayout;
    QPushButton *generateBtn;
    QPushButton *sortBtn;
    QPushButton *stepBtn;
    QPushButton *resetBtn;
    QSpinBox *arraySizeSpinBox;
    QLabel *statusLabel;
    
    QGraphicsScene *scene;
    QGraphicsView *view;
    
    QVector<int> array;
    QTimer *sortTimer;
    
    int currentI;
    int currentJ;
    bool isSorting;
    bool isComplete;
};

#endif // BUBBLESORTWINDOW_H 